using UnityEngine;
using UnityEngine.EventSystems;

namespace WorkFlow.Utils
{
    [ExecuteAlways]
    public class SoftResolution : UIBehaviour
    {
        RectTransform _rectTransform;

        RectTransform rectTransform
        {
            get
            {
                if (_rectTransform == null)
                {
                    _rectTransform = GetComponent<RectTransform>();
                }
                return _rectTransform;
            }
        }
        public static Vector2 Size { get; private set; }
        public static event System.Action OnResolutionChange;
        protected override void Awake()
        {
            base.Awake();
            Size = rectTransform.rect.size;
        }

        protected override void OnRectTransformDimensionsChange()
        {
            Size = rectTransform.rect.size;
            OnResolutionChange?.Invoke();
        }
    }
}